<template>
    <nav class="nav">
      <!--标题-->
      <div class="nav-tit">
        <i class="icon iconfont icon-rentou"></i>
        <span>个人中心</span>
      </div>
      <ul class="nav-ul">
        <li v-for="(item, index) in nav" :key='index' :class="active == item.id?'active':''" @click="toggleActive(item.id)">{{item.name}}</li>
        <!-- <li>安全设置</li> -->
      </ul>
    </nav>
</template>

<script>
    export default {
        name: "leftNav",
        data(){
          return{
            active: 1,
            nav:[
              {
                id: 1,
                name: '基本资料'
              },
              {
                id: 2,
                name: '安全设置'
              },
            ]
          }
        },
        methods:{
          toggleActive(e){
            this.active = e
            this.$emit('personal', e)
          }
        }
    }
</script>

<style scoped>
  @import "../../../static/personal/iconfont.css";
  .nav{
    position: fixed;
    top: 123px;
    left: 0;
    height: calc(100vh - 123px);
    width: 120px;
    border-right: 1px solid #d0d1d2;
    z-index: 1;
  }
  .nav-tit{
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 15px 10px;
    font-size: 14px;
    position: relative;
  }
  .nav-tit .iconfont{
    position: absolute;
    left: 10px;
    color: rgb(21, 144, 237);
  }
  .nav-ul li{
    padding: 10px;
    border-top: 1px solid #ddd;
    text-align: center;
    font-weight: 500;
    cursor: pointer;
  }
  .nav-ul li:last-child{
    border-bottom: 1px solid #ddd;
  }
  .nav-ul li:hover,
  .nav-ul li.active{
    background: #e8e8e8;
  }

</style>
